<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>阜安街道智慧党建平台</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <script src="assets/js/echarts.min.js"></script>
    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="stylesheet" href="assets/css/amazeui.datetimepicker.css">
    <link rel="stylesheet" href="assets/kindeditor/themes/default/default.css">
    <link rel="stylesheet" href="assets/kindeditor/plugins/code/prettify.css" />
    <link rel="stylesheet" href="assets/css/main.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <script src="assets/js/jquery.min.js"></script>
    <script>
        let name = sessionStorage.getItem("username");
        if (name == null) {
            alert("您还未登录，请登录！");
            window.location.href = "login.html";
        }
        let user_id = sessionStorage.getItem("user_id");
        let user_name = sessionStorage.getItem("realname");
        
    </script>
    <style>
        #title1{
            font-size: 12px;
        }
        #title2{
            font-size: 14px;
            text-align: center;
            color: red;
        }
        .FormTable2{
            border-collapse: collapse !important;
            border-spacing: 0 !important;
            width: 100%;
        }
        .FormTable2 td{
            color: #5f94b4;
            padding-left: 5px !important;
            padding-right: 5px !important;
           
            line-height: 150% ;
            height: 40px !important;
           font-size: 16px !important;
           border: 1px solid #5b779e !important;
  
        }
        .FormTable2 tr td:nth-child(2){
            text-align: left;
        }
    </style>
    <style>
        .am-form-group{
            margin-bottom: 4px;
        }
        @media screen and (min-width: 641px){
            .ke-container{
                width: 670px !important;
            }
        }
        @media screen and (min-width: 641px){
            .box_lable{
                width: 110px;
            }
        }
        .yianTable{
            min-width: 900px;
        }
        .flexMenu p{
            margin: 5px 0;
            font-size: 12px;
            max-width: 85px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: normal;
        }
    </style>
</head>
<body data-type="index">
<script src="assets/js/theme.js"></script>
<div class="am-g tpl-g">
<!-- 头部 -->
<div id="personSettings"></div>
<header class="main_header">
    <!-- 右侧内容 -->
    <div class="tpl-header-fluid">
        <!-- 其它功能-->
        <div class="am-fr tpl-header-navbar">
            <ul>
                <!-- 欢迎语 -->
                <li class="am-text-sm tpl-header-navbar-welcome">
                    <a href="javascript:;">欢迎你, <span id="name"></span> </a>
                </li>
                <!--个人设置-->
                <li class="am-text-sm" data-am-modal="{target: '#settings'}" onclick="settings()">
                    <a href="javascript:;">
                        <span class="am-icon-user"></span> 个人设置
                    </a>
                </li>
                <!--退出系统-->
                <li class="am-text-sm" onclick="exit()">
                    <a href="javascript:;">
                        <span class="am-icon-sign-out"></span> 退出系统
                    </a>
                </li>
            </ul>
        </div>
    </div>
</header>
    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="am-panel am-panel-default" id="postId">
            <div class="am-panel-bd" style="display: flex;justify-content: flex-start;align-items: center">
                <a class="flexMenu" href="integral_ranking.html?type=2">
                    <img src="assets/img/Duty_RD_Meet.png">
                    <p>机关党支部</p>
                </a>
                <a class="flexMenu" href="integral_ranking.html?type=3">
                    <img src="assets/img/chuque.png">
                    <p>村居党支部</p>
                </a>
                <a class="flexMenu" href="integral_ranking.html?type=4">
                    <img src="assets/img/Duty_RD_Meet.png">
                    <p>教育党支部</p>
                </a>
                <a class="flexMenu" href="integral_ranking.html?type=5">
                    <img src="assets/img/DutyService_RD.png">
                    <p>“两新”党支部</p>
                </a>
                <!-- <a class="flexMenu" href="integral_ranking.html?type=6">
                    <img src="assets/img/dbxx.png">
                    <p>社区党委</p>
                </a> -->
                <div class="flexMenu" id="backup">
                    <img src="assets/img/backup.png">
                    <p>返回</p>
                </div>
            </div>
        </div>       
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-body  am-fr">
                            <div class="am-u-sm-6 am-u-md-4 am-u-lg-2">
                                <button class="am-btn am-btn-sm am-btn-success am-radius add_desc">
                                    生成积分信息    
                                </button>
                            </div>
                            <!-- <div class="am-u-sm-6 am-u-md-4 am-u-lg-2" style="text-align: center;">
                                <select name="" id="" class="pageSize">
                                    <option value="15">每页显示数</option>
                                    <option value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="25">25</option>
                                    <option value="30">30</option>
                                    <option value="50">50</option>
                                    <option value="80">80</option>
                                    <option value="80">100</option>
                                    <option value="80">150</option>
                                    <option value="200">200</option>
                                    <option value="300">300</option>
                                    <option value="500">500</option>
                                    <option value="1000">1000</option>
                                </select>
                            </div>
                            <div  class="am-u-sm-6 am-u-md-4 am-u-lg-1">
                                <input  type="text" id="years" class="am-form-field" data-am-datepicker="{format: 'yyyy ', viewMode: 'years', minViewMode: 'years'}" placeholder="选择年份" data-am-datepicker >
                            </div> -->
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3 am-fr">
                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                   <input type="text" class="am-form-field " placeholder="搜索" id="input">
                                    <span class="am-input-group-btn">
                                        <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search search_type1" type="button"></button>
                                    </span>
                                </div>
                            </div>

                            <div class="am-u-sm-12 am-scrollable-horizontal" style="margin-top: 10px;">
                                <table width="100%" id="table" class=" am-table-hover am-text-nowrap am-table-bordered am-table-centered am-table am-table-compact am-table-striped tpl-table-black ">
                                    <thead>
                                    <tr>
                                        <th></th>
                                        <th>√</th>
                                        <th>单位名称</th>
                                        <th>本月度工作</th>
                                        <th>其他工作</th>
                                        <th>年度累计积分</th>
                                        <th class="dy">
                                            党员积分排名
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody  id="show">

                                    <!-- more data -->
                                    </tbody>
                                </table>
                            </div>
                            <div class="am-u-lg-12 am-cf">
                                <div class="am-fl">
                                    <!-- <label class="am-fl" style=" margin: 1.5rem 10px;">
                                        <input type="checkbox" name="selectAll" id="checkAll" >
                                        全选
                                    </label> -->
                                    <!-- <button class="am-btn am-btn-sm am-btn-danger am-fl detele">
                                        删除
                                    </button> -->
                                    <button class="am-btn am-btn-sm am-btn-secondary am-fl d_excle" id="excel">
                                        导出EXCEL
                                    </button>
                                </div>
                                <div class="am-fr">
                                    <ul class="fenye fenye_zz am-pagination tpl-pagination">
                                        <li class="am-active"><a class="first" href="#">首页</a></li>
                                        <li><a href="#" class="up">上一页</a></li>
                                        <li><a href="#" class="down">下一页</a></li>
                                        <li><a class="last" href="#">末页</a></li>
                                        <li>
                                            <a href="javascript:void(0)" style="border: none;">
                                                页次:<span class="page_c"></span>/<span class="pagenum_c"></span>页 
                                                <span class="strip_c"></span>条/页
                                            </a>
                                        </li>
                                        <li>
                                            <a href="javascript:void(0)" style="padding: 0">
                                                <input class="go_page_c" type="text" value="">
                                            </a>
                                        </li>
                                        <li class="go_page_search">
                                            <a href="#">
                                                GO
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>   
    </div>
</div>



<!-- 确认提示 -->
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm" style="z-index: 1320">
  <div class="am-modal-dialog">
    <div class="am-modal-hd"></div>
    <div class="am-modal-bd">
      确定要删除这条记录吗？
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
<!-- 模拟弹框alert -->
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert" style="z-index: 1310">
  <div class="am-modal-dialog">
    <div class="am-modal-bd show_desc">
      
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/amazeui.datatables.min.js"></script>
<script src="assets/js/dataTables.responsive.min.js"></script>
<script src="assets/js/amazeui.datetimepicker.min.js"></script>
<script src="assets/js/amazeui.datetimepicker.zh-CN.js"></script>
<script src="assets/js/app.js"></script>
<script src="assets/kindeditor/kindeditor-all.js"></script>
<script src="assets/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="assets/kindeditor/plugins/code/prettify.js"></script>
<script>
    KindEditor.ready(function(K) {
            K.create('#content1', {
                uploadJson: testurl + 'kindeditor/',
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
            },
            afterBlur: function () { this.sync(); }//这一步非常重要，如果遗漏，则后台无法接收到数据。
            });
        prettyPrint();   
    });
</script>
<script>
    $(function () {
        //时间插件
        $(".add_desc").click(function(){
            location.reload()
        })
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg); //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }
        var type_x =getUrlParam('type');
        if(type_x=="2"){
            
            $(".am-panel-bd a").eq(0).addClass("menu-bg").siblings().removeClass("menu-bg")
        }
        if(type_x=="3"){
            
            $(".am-panel-bd a").eq(1).addClass("menu-bg").siblings().removeClass("menu-bg")
            //$("#status").html("<option value='1'>视察调研活动</option>")
        }
        if(type_x=="4"){
            
            $(".am-panel-bd a").eq(2).addClass("menu-bg").siblings().removeClass("menu-bg")
            //$("#status").html("<option value='1'>视察调研活动</option>")
        }
        if(type_x=="5"){
            
            $(".am-panel-bd a").eq(3).addClass("menu-bg").siblings().removeClass("menu-bg")
            //$("#status").html("<option value='1'>视察调研活动</option>")
        }
        if(type_x=="6"){
            
            $(".am-panel-bd a").eq(4).addClass("menu-bg").siblings().removeClass("menu-bg")
            //$("#status").html("<option value='1'>视察调研活动</option>")
        }
        let token = sessionStorage.getItem("token");
        let companyId = sessionStorage.getItem("companyId");
        console.log(companyId)
        var pages =1;
        var years=""
        var condition=""
        var pageSize="15"
        function loadData(pageNum){
            $.ajax({
                url: testurl+"/integral/listRanking",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                    "company_name":condition,//单位名称模糊查询
                    "pageNum":pageNum,
                    "pid":type_x//2、机关单位 3、村支部 4、教育单位 5、企业 6、社区党委
                }),
                success: function (data) {
                    var data_dictionary = data.obj;
                    console.log(data_dictionary)
                    ssd = Math.ceil(data.pageTotal/data.pageSize);
                    pages = ssd;
                    str = "";
                    
                    $.each(data_dictionary,function (index,values) {
                        var num_bz=index+1
                        if (values.userId=="合计") {
                        }
                        else{
                            if (companyId =="1") {
                                str += " <tr class=\"gradeX\">\n" +
                                "<td>"+num_bz+"</td>"+
                                "                                        <td>"+"<input name=\"selectAll\" value="+values.id+" type=\"checkbox\" />"  +"</td>\n" +
                                "                                        <td><a href=\"dw_list.html?type="+"1"+"&&nameid="+values.company_id+"\">"+values.company_name+"</a></td>\n" +
                                // "                                        <td><a href=\"javascript:void(0)\" onclick=\"show_bg("+values.user_id+")\">"+values.company_name+"</a></td>\n" +
                                
                                "                                        <td>"+values.benyuejifen+"</td>\n" +
                                "                                        <td>"+values.qitagongzuo+"</td>\n" +
                                
                                "                                        <td>"+values.integral_calculus+"</td>\n"
                                +
                                "                                        <td class=\"dy\"><a href=\"dy_ranking.html?id="+values.company_id+"\">党员积分排名</a></td>\n"
                            
                                
                                "                                    </tr>"
                            }
                            else if(companyId == values.company_id) {
                                str += " <tr class=\"gradeX\">\n" +
                                "<td>"+num_bz+"</td>"+
                                "                                        <td>"+"<input name=\"selectAll\" value="+values.id+" type=\"checkbox\" />"  +"</td>\n" +
                                "                                        <td>"+values.company_name+"</td>\n" +
                                // "                                        <td><a href=\"javascript:void(0)\" onclick=\"show_bg("+values.user_id+")\">"+values.company_name+"</a></td>\n" +
                                
                                "                                        <td>"+values.benyuejifen+"</td>\n" +
                                "                                        <td>"+values.qitagongzuo+"</td>\n" +
                                
                                "                                        <td>"+values.integral_calculus+"</td>\n"
                                +
                                "                                        <td class=\"dy\"><a href=\"dy_ranking.html?id="+values.company_id+"\">党员积分排名</a></td>\n"
                            
                                
                                "                                    </tr>"
                            }else{
                                str += " <tr class=\"gradeX\">\n" +
                                "<td>"+num_bz+"</td>"+
                                "                                        <td>"+"<input name=\"selectAll\" value="+values.id+" type=\"checkbox\" />"  +"</td>\n" +
                                "                                        <td>"+values.company_name+"</td>\n" +
                                // "                                        <td><a href=\"javascript:void(0)\" onclick=\"show_bg("+values.user_id+")\">"+values.company_name+"</a></td>\n" +
                                
                                "                                        <td>"+values.benyuejifen+"</td>\n" +
                                "                                        <td>"+values.qitagongzuo+"</td>\n" +
                                
                                "                                        <td>"+values.integral_calculus+"</td>\n"
                                +
                                "                                        <td class=\"dy\"></td>\n"
                                
                                "                                    </tr>"
                            }
                        }
                    });
                    $("#show").html(str);
                    $(".pagenum_c").html(pages)
                    if (pageNum>=pages) {
                        pageNum=pages
                    }
                    $(".strip_c").html(data.pageSize)
                    $(".page_c").html(pageNum)
                    
                }
            });
        }
        loadData(1);
        //分页
        var pageNum = 1;
        $(".first").click(function(){
         pageNum =1;
            loadData(pageNum);
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".last").click(function(){
            pageNum = $(".pagenum_c").text().trim()
            loadData(pageNum);
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".up").click(function(){
            pageNum=$(".page_c").text().trim()
            if(pageNum == 1){
                return false;
            } else{
                pageNum--;
                loadData(pageNum);
            }
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".down").click(function(){
            pageNum=$(".page_c").text().trim()
            if(pageNum == pages){
                return false;
            } else{
                pageNum++;
                loadData(pageNum);
            }
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".go_page_search").click(function(){
            var pageNum_c=$(".go_page_c").val().trim()
             if (isNaN(pageNum_c)||pageNum_c=="") {
                $(".show_desc").html("只能为数字");
                $('#my-alert').modal({target: '#my-alert'});
                $(".go_page_c").val("")
                return
            }
            loadData(pageNum_c);
            $(".go_page_c").val("")
        })

        //查找
        $(".search_type1").click(function(){
            condition=$("#input").val().trim()
            // pageSize=$(".pageSize").val()
            // years=$("#years").val().trim()
            loadData(1)
        })
        // $("#years").change(function(){
        //     condition=$("#input").val().trim()
        //     pageSize=$(".pageSize").val()
        //     years=$("#years").val().trim()
        //     loadData(1) 
        // })
        // $(".pageSize").change(function(){
        //     condition=$("#input").val().trim()
        //     pageSize=$(".pageSize").val()
        //     years=$("#years").val().trim()
        //     loadData(1) 
        // })
         $('#checkAll2[name="selectAll2"]').click(function(){
            if($(this).is(':checked')){
                //var deletelid1=[]
                $('#show input[name="selectAll2"]').each(function(i){
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked",true);
                });
            }else{
                $('input[name="selectAll2"]').each(function(){
                    $(this).removeAttr("checked",false);
                });
            }
        });
        //选中所有的checkbox框
        $('#checkAll[name="selectAll"]').click(function(){
            if($(this).is(':checked')){
                //var deletelid1=[]
                $('#show input[name="selectAll"]').each(function(i){
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked",true);
               
                });
            }else{
                $('input[name="selectAll"]').each(function(){
                    $(this).removeAttr("checked",false);
                });
            }
        });
        //选中所有的checkbox框
        $('#checkAlla[name="selectAlla"]').click(function(){
            if($(this).is(':checked')){
                //var deletelid1=[]
                $('input[name="selectItema"]').each(function(i){
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked",true);
               
                });
            }else{
                $('input[name="selectItema"]').each(function(){
                    $(this).removeAttr("checked",false);
                });
            }
        });
        //选中所有的checkbox框
        $('#checkAll1[name="selectAll1"]').click(function(){
            if($(this).is(':checked')){
                //var deletelid1=[]
                $('#show1 input[name="selectAll1"]').each(function(i){
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked",true);
               
                });
            }else{
                $('input[name="selectAll1"]').each(function(){
                    $(this).removeAttr("checked",false);
                });
            }
        });
        //导出excel     
        $(".d_excle").click(function () {
            var condition=$("#input").val()
            let loactionHref = testurl+"/integral/exportListRanking?";
            window.open(loactionHref + "&pid=" + type_x + "&company_name=" + condition);
        });
        
    })
</script>
</body>
</html>